package cn.gaily.eduservice.controller;


import cn.gaily.commonutils.R;
import cn.gaily.eduservice.entity.EduComment;
import cn.gaily.eduservice.entity.vo.EduCommentVo;
import cn.gaily.eduservice.service.EduCommentService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 评论 前端控制器
 * </p>
 *
 * @author xuchengwei
 * @since 2021-08-09
 */
@RestController
@RequestMapping("/eduservice/edu-comment")
public class EduCommentController {
    @Autowired
    EduCommentService eduCommentService;

    @ApiOperation(value = "分页查询评论")
    @PostMapping("/getComment/{courseId}/{page}/{limit}")
    public R getComment(@PathVariable String courseId,
                        @PathVariable long page,
                        @PathVariable long limit){
        Page<EduComment> eduCommentPage = new Page<>(page,limit);
        List<EduCommentVo> comment = eduCommentService.getComment(eduCommentPage, courseId);
        return R.ok().data("comment",comment);
    }
}

